# !/usr/bin/env python
# -*-coding:utf-8 -*-
# python -m pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --upgrade pip

"""
配置文件 config类, 便于更改键值并保存文件, 其他功能有待扩展
"""
import configparser


class Config(configparser.ConfigParser):

    def __init__(self, file_path: str):
        super().__init__()
        self.file_path = file_path
        self.read(file_path, encoding='utf-8')

    def set_save(self, section: str, key: str, value: str):
        """
        更改键值并保存

        :param section: 节点
        :param key: 键
        :param value: 值
        """
        self.set(section, key, value)
        self.write(open(self.file_path, 'w'))
